local sharedLibs = game.ReplicatedStorage.SharedLibs;
local pt = require(sharedLibs.Prototype)

local cls = pt.proto();

function cls:constructor()
	self._arr = { nil };
	self._n = 0;
	self._Len = 1;
end

function cls:Push(value)
	self._arr[self._n] = value
	self._n = self._n + 1
	if self._n == self._Len then
		self:Resize(self._Len * 2)
	end
end

function cls:Peek()
	if self._n == 0 then
		return nil
	end

	local value = self._arr[self._n-1]
	return value;
end

function cls:Pop()
	if self._n == 0 then
		return nil
	end

	local value = self._arr[self._n-1]
	self._n = self._n - 1

	if self._n == math.floor(self._Len / 4) then
		self:Resize(math.floor(self._Len / 2))
	end
	return value
end

function cls:Resize(newSize)
	local temp = {}
	for i = 0,(newSize-1) do
		temp[i] = self._arr[i]
	end

	self._arr = temp
	self._Len = newSize
end

function cls:Size()
	return self._n
end

function cls:IsEmpty()
	return self._n == 0
end

function cls:Enumerate()
	local temp = {}
	for i = 0,(self._n-1) do
		temp[i] = self._arr[i]
	end
	return temp
end

return cls;